package com.xinnet.mms.customerManage.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.xinnet.core.dao.BaseDao;
import com.xinnet.core.utils.page.PageView;
import com.xinnet.mms.entity.Area;
import com.xinnet.mms.entity.CustomMixAudit;
import com.xinnet.mms.entity.Customer;
import com.xinnet.mms.entity.CustomerCare;
import com.xinnet.mms.entity.CustomerRemark;
import com.xinnet.mms.entity.Dept;
import com.xinnet.mms.entity.Emp;
import com.xinnet.mms.entity.EmpCustomRelation;
import com.xinnet.mms.entity.Product;
import com.xinnet.mms.entity.PushHistory;
import com.xinnet.mms.entity.PushResults;

@Repository
public interface CustomerManageDao extends BaseDao<Customer,Long>{
	
	public List<Customer> getAllCustom();
	
	/**
	 * 
	 * 方法描述：接收客户
	 * 
	 *@param customer
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-1-20 下午11:31:56
	 */
	public void addEmpCustomRelation(EmpCustomRelation empCustomRelation);
	
	public void updateCustomer(Customer customer);
	public void updateCustomerProduct(Customer customer);
	public void  goOpenSea(Customer customer);
	
	public void newRegisterCustomTransfer(String customId);
	/**
	 * 批量更新公海客户为服务期客户
	 * @param customIdList
	 */
	public void batchUpateOpenSeaCustom(List<String> customIdList);
	
	public List<Customer> queryAllCustomerByType(PageView<Customer> pageView, Customer customer);
	
	/**
	 * 
	 * 方法描述：修改客户
	 * 
	 *@param customer
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-1-20 下午11:32:49
	 */
	public void modifyCustomerById(Customer customer);
	
	/**
	 * 
	 * 方法描述：添加客户
	 * 
	 *@param customer
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-1-20 下午11:34:43
	 */
	public void addCustomer(Customer customer);
	
	/**
	 * 
	 * 方法描述：服务器客户在接收客户时 需要修改人员ID为当前登录用户ID
	 * 
	 *@param customerCare 客户服务VO
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-1-23 下午4:20:55
	 */
	public void updateCustomerCareeEmpno(CustomerCare customerCare);
	
	/**
	 * 
	 * 方法描述：通过产品ID查询出对应的组织结构
	 * 
	 *@param customerId
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-1-24 下午2:56:58
	 */
	public List<Dept> getDeptByProductIds(Dept dept);
	
	public void delCustomByCname(String customName);
	
	public void addCustom(Customer customer);
	
	/**
	 * 
	 * 方法描述：根据部门ID获取所对应的区域
	 * 
	 *@param deptId
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-18 下午2:04:01
	 */
	public List<Area> getAreaByDeptId(String deptId);

	/**
	 * 
	 * 方法描述：通过客户电话跟邮箱查询客户
	 * 
	 *@param customer
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-7 下午3:38:10
	 */
	public Customer queryCustomerByPhoneAndEmail(Customer customer);
	
	/**
	 * 
	 * 方法描述：通过客户电话或邮箱查询客户
	 * 
	 *@param customer
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-7 下午3:38:10
	 */
	public List<Customer> queryCustomerByPhoneOrEmail(Customer customer);
	
	public Customer queryCustomerByPhone(Customer customer);
	
	public Customer queryCustomerByEmail(Customer customer);
	
	/**
	 * 
	 * 方法描述：通过客户ID删除客户
	 * 
	 *@param customerId 客户ID
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-7 下午5:09:01
	 */
	public void delCustomerByIds(Customer customer);
	
	public List<Customer> getOfServiceCustomerByEmpNoStr(String empNoStr);
	
	
	public void addCustomMixAudit(CustomMixAudit customMixAudit);
	
	public List<CustomMixAudit> getAllCustomMixAudit();
	
	public List<Customer> getOfServiceCustomer(Map<String,Object> param);
	
	public List<CustomMixAudit> getCustomDeployApprovalItems(String deptIdStr,String approvalerId);
	
	public List<CustomMixAudit> getCustomMixAudit(Map<String,Object> param);
	
	public Integer getCustomMixAuditCount(Map<String,Object> param);
	
	public int updateCustomMixAudit(CustomMixAudit customMixAudit) throws Exception;
	
	public void updateCustomMixAuditFlagByCustomMixId(String customMixId);
	
	/**
	 * 
	 * 方法描述：查询报备客户
	 * 
	 *@param pageView
	 *@param customer
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-20 下午4:04:35
	 */
	public List<Customer> queryReportedCustomer(PageView<Customer> pageView,Customer customer);
	
	/**
	 * 
	 * 方法描述：通过查询条件获取客户服务
	 * 
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-20 下午4:06:58
	 */
	public CustomerCare getCustomerCareByCondition(CustomerCare customerCare);

	/**
	 * 
	 * 方法描述：根据父产品ID来获取产品
	 * 
	 *@param parentId
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-21 下午1:19:30
	 */
	public List<Product> getProductByParentId(String parentId);

	/**
	 * 
	 * 方法描述：通过条件获取客户服务（订单）
	 * 
	 *@param customerId
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-24 上午11:06:33
	 */
	public List<CustomerCare> getCustomerCareListByCondition(
			CustomerCare customerCare);

	/**
	 * 
	 * 方法描述：通过客户ID查询出该客户未被推送过的产品
	 * 
	 *@param cusId
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-25 下午2:42:32
	 */
	public List<Product> getNotPushProductByCustomerId(String cusId);

	
	/**
	 * 
	 * 方法描述：添加客户备注
	 * 
	 *@param customerRemark
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-26 上午10:52:48
	 */
	public void addCustomerRemark(CustomerRemark customerRemark);
	
	/**
	 * 
	 * 方法描述：查询客户备注
	 * 
	 *@param pageView
	 *@param customerRemark
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-26 上午10:38:11
	 */
	public List<CustomerRemark> queryCustomerRemark(
			PageView<CustomerRemark> pageView, CustomerRemark customerRemark);
	
	/**
	 * 
	 * 方法描述：查询客户备注
	 * 
	 *@param pageView
	 *@param customerRemark
	 *@return
	 *
	 * @author 王志军[wangzhijun@xinnet.com]
	 *
	 *	       2016-6-2 上午10:38:11
	 */
	public List<CustomerRemark> queryCustomerRemark(CustomerRemark customerRemark);
	
	
	/**
	 * 
	 * 方法描述：通过客户备注主键ID修改客户备注
	 * 
	 *@param customerRemark
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-3-5 下午1:56:44
	 */
	public void modifyCustomerRemarkById(CustomerRemark customerRemark);

	/**
	 * 
	 * 方法描述：通过推送历史ID修改推送历史记录
	 * 
	 *@param pushHistory
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-27 下午3:33:54
	 */
	public void updatePushHistoryById(PushHistory pushHistory);

	/**
	 * 
	 * 方法描述：通过客户ID集合获取客户
	 * 
	 *@param customer
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-2-28 下午4:23:10
	 */
	public List<Customer> getCustomerByIdArray(Customer customer);
	/**
	 * 
	 * 功能描述：删除400客户
	 *
	 * @param cusId
	 *
	 * @author 王湛智[wangzhanzhi@xinnet.com]
	 *
	 * @since 2014年3月11日
	 *
	 * @update:[变更日期YYYY-MM-DD][更改人姓名][变更描述]
	 */
	public void del400Customer(String cusId);
	/**
	 * 
	 * 功能描述：查询客户是否在客户服务表中有记录
	 *
	 * @param cusId
	 * @return
	 *
	 * @author 王湛智[wangzhanzhi@xinnet.com]
	 *
	 * @since 2014年3月11日
	 *
	 * @update:[变更日期YYYY-MM-DD][更改人姓名][变更描述]
	 */
	public Integer isBuy(String cusId);

	/**
	 * 
	 * 方法描述：根据销售人员ID 跟 产品ID查询推送历史表 获取推送个数 用于首页展示意向客户 推送个数
	 * 
	 *@param statPushResults
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-3-13 下午4:07:44
	 */
	public List<PushResults> getPushNumber(PushResults pushResults);

	/**
	 * 
	 * 方法描述：获取客户的意向商品
	 * 
	 *@param cusId
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-3-14 下午2:38:30
	 */
	public List<Product> getIntentionProduct(String cusId);

	/**
	 * 
	 * 方法描述：根据员工部门ID获取员工
	 * 
	 *@param deptId
	 *@return
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-3-19 下午1:23:11
	 */
	public List<Emp> getEmpListByDeptId(String deptId);

	/**
	 * 
	 * 方法描述：cusId
	 * 
	 *@param cusId
	 *
	 * @author 李丽华[lilihua@xinnet.com]
	 *
	 *	       2014-3-21 下午4:38:18
	 */
	public void updateIsRecyclingByCusId(String cusId);
	
	/**
	 * 更新客户类型
	 * @param customType
	 */
	public void updateCustomType(Customer customer);

	
	/**
	 * 根据流传历史ID查询记录
	 * @param pushHistoryId  流转历史ID
	 */
	public PushHistory getPushHistoryById(String pushHistoryId);

	/**
	 * 通过产品ID获取产品
	 * @param productId
	 * @return
	 */
	public Product getProductByProductId(String productId);

	
	/**
	 * 通过销售ID与客户状态获取客户
	 * @param page 分页插件
	 * @param customer 客户VO
	 * @return
	 */
	public List<Customer> getCustomerByEmpIdAndCustomState(PageView<Customer> page,
			Customer customer);

	/**
	 * 获取所有产品
	 * @return
	 */
	public List<Product> getAllProduct();
	
	public List<Customer> getDeployCustomByMap(Map<String,Object> paramMap);
	//public List<Customer> getDeployCustomByDeptIdAndApplyerId(String deptId,String applyerId);

	public Integer getDeployCustomCountByMap(Map<String,Object> paramMap);

	public List<Customer>  getDeployCustomByParam(Map<String, Object> param);
	
	public Integer  getDeployCustomCountByParam(Map<String, Object> param);
	
	public Customer getDeployCustomByCustomMixId(String customMixId);
	
	/**
	 * 根据销售人员ID与客户类型获取所有客户
	 * @param customer
	 * @return
	 */
	public List<EmpCustomRelation> getCustomerByEmpIdAndCustomType(Customer customer);
	
	
	public void updateCustomMixAuditStatusByDeptIdStr(String deptIdStr);

	public List<CustomMixAudit>  getCustomMixAuditByEcrIdAndFromEmpId(String ecrId,String fromEmpId);
	/**
	 * 获取所有未接收的客户
	 * @param customer
	 * @return
	 */
	public List<Customer> getAllNotAcceptCustom(Customer customer);
	
	public List<Customer> getTestCustomer(Customer customer);

	/**
	 * 通过客户类型获取未接收的客户
	 * @param customer
	 * @return
	 */
	public Integer getAcceptNoCustomerCountByCustomType(Customer customer);

	/**
	 * 获取即将流走客户数量
	 * @param customer
	 * @return
	 */
	public Integer getVanishSoonCustomerCount(Customer customer);
	
	/**
	 * 查询客户购物车记录数
	 * @param customer
	 * @return
	 */
	public Integer getShopCartCustomerCount(Customer customer);
	/**
	 * 查询客户购物车
	 * @param customer
	 * @return
	 */
	public List<Customer> queryShopCartCustomer(
			Customer customer);
	
	/**
	 * 查询公海客户
	 * @param page
	 * @param customer
	 * @return
	 */
	public List<Customer> queryOpenSeeCustomer(PageView<Customer> page,
			Customer customer);

	/**
	 * 获取客户列表
	 * @param pageView
	 * @param customer
	 * @return
	 */
	public List<Customer> getCustomerList(PageView<Customer> pageView,
			Customer customer);
	
	/**
	 * 获取总记录数
	 * @return
	 */
	public Integer count(Customer customer);
	
	/**
	 * 获取客户列表(新)
	 * @param customer
	 * @return
	 */
	public List<Customer> getCustomerList(Customer customer);
	
	/**
	 * 获取总记录数(新)
	 * @return
	 */
	public Integer getCustomerCount(Customer customer);
	
	public List<CustomMixAudit> getCustomDeployApprovalItemsByMap(Map<String,Object> paramMap);

	public Integer getCustomDeployApprovalItemsCountByMap(Map<String,Object> paramMap);

	/**
	 * 获取报备客户的总记录数
	 * @param customer
	 * @return
	 */
	public Integer getReportedCustomerCount(Customer customer);

	/**
	 * 获取公海客户的总记录数
	 * @param customer
	 * @return
	 */
	public Integer getOpenSeeCustomerCount(Customer customer);
	
	/**
	 * 获取加入购物车会员的数量
	 * @param customer
	 * @return
	 */
	public Integer getAddShopCartCustomerCount(Customer customer);

	/**
	 * 获取客户条数
	 * @param customer
	 * @return
	 */
	public Integer getAllfitCustomNum(Customer customer);

	/**
	 * 查询意向客户
	 * @param customer
	 * @return
	 */
	public List<Customer> getAllMindCustom(Customer customer);

	public List<Customer> getAllWaitChargeCustom(Customer customer);

	public List<Customer> getAllProtectCustom(Customer customer);

	public List<Customer> getAllSecondCustom(Customer customer);
	
	public Customer getCustomById(Customer customer);
}
